<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>发展客户</title>
		<link rel="stylesheet" href="$!rc.contextPath/common/common.css" />
		<link rel="stylesheet" type="text/css" href="$!rc.contextPath/css/mycollect.css"/>
		<link rel="stylesheet" href="$!rc.contextPath/common/dropload.css" />
		<style type="text/css">
		.href-bg{
			z-index: 999;
		}
		
		/*寮瑰嚭妗嗘牱寮�*/
		.href-bg {
		    position: fixed;
		    bottom: 0;
		    width: 100%;
		    height: 100%;
		    background: rgba(0,0,0,0.3);
		    display: none;
		}
		.herf {
		    display: flex;
		    flex-direction: column;
		    position: absolute;
		    bottom: 0;
		    align-items: center;
		    width: 100%;
		    background: #eeeeee;
		}
		.herf-list-title {
		    height: 3.5rem;
		    background: #3794e2;
		    line-height: 3.5rem;
		    width: 100%;
		    text-align: center;
		    font-size:1.4rem;
		    color: #fff;
		}
		.herf-list {
		    width: 100%;
		}
		.btn-cancle {
		    margin-top: 0.5rem;
		    background: #fff;
		    width: 100%;
		    font-size: 1.3rem;
		    height: 4rem;
		    line-height: 4rem;
		    text-align: center;
		}
		.herf-list li {
		    margin-top: 0.5rem;
		    background: #fff;
		    width: 100%;
		    font-size: 1.3rem;
		    height: 4rem;
		    line-height: 4rem;
		    text-align: center;
		}
		.yes, .no {
		    width: 17rem;
		    color: #ffffff;
		    height: 3rem;
		    line-height: 3rem;
		    margin: 0 auto;
		    border-radius: 20px;
		    text-align: center;
		    margin-bottom:1.3rem;
		}
		.yes {
		    background: #3794e2;
		}
		.no {
		    background: #ababab;
		}
		</style>
	</head>
	<body>
		<!--顶部-->
		<div class="title text-center">
			<a onClick="javascript:window.history.go(-1)"><</a>
			发展客户
		</div>
		<article>
			<div class="content">
				<ul class="block lists">
					
				</ul>
				<div class="href-bg">
					<div class="herf">
						<p class="herf-list-title">请选择会员类型</p>
						<ul class="herf-list">
								<li val="1">
									<div>银卡会员</div>
								</li>
								<li val="2">
									<div>金卡会员</div>
								</li>
						</ul>
						<div class="btn-cancle">取消</div>
					</div>
				</div>
			</div>
		</article>
		
	</body>
	<script src="$!rc.contextPath/common/jquery-1.8.3.min.js" type="text/javascript"></script>
	<script src="$!rc.contextPath/common/dropload.min.js"></script>
	<script type="text/javascript">
		//清除浮动
		$(".content ul").css("clear","both");
		//tab选项卡
		$(".headlines-title li").click(function(){
			var Index = $(this).index();
			$(".headlines-title li").eq(Index).addClass("active").siblings().removeClass("active");
			$(".headlines-title li").eq(Index).children("span").addClass("active-line-bottom").parent().siblings().children("span").removeClass("active-line-bottom");
			$(".content ul").eq(Index).addClass("block").siblings().removeClass("block");
	
		})
	</script>
	<script type="text/javascript">
		$(function(){
			f_init();
		})
		
		function f_init(month){
			$(".lists").empty();
			$(".dropload-down").remove();
			
			var counter = 0;
		    // 每页展示4个
		    var num = 10;
		    var pageStart = 0,pageEnd = 0;
		
		    // dropload
		    $('.content').dropload({
		        scrollArea : window,
		        domUp : {
		            domClass   : 'dropload-up',
		            domRefresh : '<div class="dropload-refresh">↓下拉刷新</div>',
		            domUpdate  : '<div class="dropload-update">↑释放更新</div>',
		            domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>'
		        },
		        domDown : {
		            domClass   : 'dropload-down',
		            domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>',
		            domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
		            domNoData  : '<div class="dropload-noData">~没有更多客户了~</div>'
		        },
		        loadDownFn : function(me){
		            $.ajax({
		                type: 'POST',
		                url: '$!rc.contextPath/member/lowerList',
		                data : {
		                	startIndex : pageStart,
		                	pageSize : num
		                },
		                dataType: 'json',
		                success: function(data){
		                    var result = '';
		                    counter++;
		                    pageEnd = num * counter;
		                    pageStart += num;
		                    if(data.code == '0'){
		                    	var list = data.data;
		                    	console.log(list);
		                    	for(var i = 0; i < list.length; i++){
		                    		var typeName;
		                    		if(list[i].member_type == '0'){
		                    			typeName = '普通会员';
		                    		}else if(list[i].member_type == '1'){
		                    			typeName = '银卡会员';
		                    		}else if(list[i].member_type == '2'){
		                    			typeName = '金卡会员';
		                    		}
		                    		result += '<li class="cancle" val="' + list[i].member_info_id + '"><div class="mycollect-list-left"><img src="' + list[i].head + '"/></div><div class="mycollect-list-middle"><p>' + list[i].member_nick + '</p>' + 
		                    					'<div class="mycollect-list-middle-bottom"><p style="text-decoration: none;"><span>' + list[i].add_time + '</span></p></div></div>' + 
		                    					'<div class="mycollect-list-right">' + typeName + '</div></li>';
			                        
		                    	}
		                    	
		                    	if(list.length < 10){
		                            // 再往下已经没有数据
		                            // 锁定
		                            me.lock();
		                            // 显示无数据
		                            me.noData();
		                            //break;
		                        }
		                    }
		
	                        $('.lists').append(result);
	                        // 每次数据加载完，必须重置
	                        me.resetload();
	                        
	                        f_loadevent();
		                },
		                error: function(xhr, type){
		                    alert('网络故障!');
		                    // 即使加载出错，也得重置
		                    me.resetload();
		                }
		            });
		        },
		        threshold : 50
		    });
		}
		
		var mid = 0;
		
		function f_loadevent(){
			//弹出框取消订单
	        $(".cancle").on("click",function(){
	        	mid = $(this).attr("val");
	        	$(".href-bg").fadeIn();
	        })
	        $(".herf-list li").on("click",function(){
	        	f_set_type($(this).attr("val"))
	        	$(".href-bg").fadeOut();
	        })
	        $(".btn-cancle").on("click",function(){
	        	$(".href-bg").fadeOut();
	        })
		}
		
		function f_set_type(type){
			var str = "";
			if(type == 1){
				str = "银卡会员";
			}else if(type == 2){
				str = "金卡会员";
			}
			if(confirm("确定设置该会员成为" + str + "吗？")){
				$.ajax({
		            type: 'POST',
		            url: '$!rc.contextPath/member/setMemberType',
		            data : {
		            	memberId : mid,
		            	type : type
		            },
		            dataType: 'json',
		            success: function(data){
		                if(data.code == '0'){
		                	location.reload();
		                }
		            }
		        }); 
			}
			
		}
	</script>
</html>
